#@head("登入")
#define main()
	<link rel="stylesheet" href="#(ctx)/assets/layuiadmin/style/login.css" media="all">
#end
<body>
	<div class="layadmin-user-login layadmin-user-display-show" id="LAY-user-login" style="display: none;">
		<div class="layadmin-user-login-main">
			<div class="layadmin-user-login-box layadmin-user-login-header">
				<h2>欢迎进入</h2>
				<p>
					JFinal后台管理系统
				</p>
			</div>
			<div class="layadmin-user-login-box layadmin-user-login-body layui-form">
				<div class="layui-form-item">
					<label class="layadmin-user-login-icon layui-icon layui-icon-username" for="LAY-user-login-username"></label>
					<input type="text" name="account" id="LAY-user-login-username" lay-verify="required" placeholder="用户名" class="layui-input">
				</div>
				<div class="layui-form-item">
					<label class="layadmin-user-login-icon layui-icon layui-icon-password" for="LAY-user-login-password"></label>
					<input type="password" name="password" id="LAY-user-login-password" lay-verify="required" placeholder="密码" class="layui-input">
				</div>
				<div class="layui-form-item">
					<div class="layui-row">
						<div class="layui-col-xs7">
							<label class="layadmin-user-login-icon layui-icon layui-icon-vercode" for="LAY-user-login-vercode"></label>
							<input type="text" name="vercode" id="LAY-user-login-vercode" lay-verify="required" placeholder="图形验证码" class="layui-input">
						</div>
						<div class="layui-col-xs5">
							<div style="margin-left: 10px;">
								<img src="#(ctx)/imageCodes" title="更换一张验证码图片" class="layadmin-user-login-codeimg" id="LAY-user-get-vercode">
							</div>
						</div>
					</div>
				</div>
				<div class="layui-form-item" style="margin-top: 30px;">
					<button class="layui-btn layui-btn-fluid" lay-submit lay-filter="LAY-user-login-submit">登 入</button>
				</div>
			</div>
		</div>
		<div class="layui-trans layadmin-user-login-footer">
			<p>
				© 2018 
				<a href="http://www.layui.com/" target="_blank">layui.com</a>
			</p>
		</div>
	</div>
	#@layui()
	#define use()
		use(["index", "form"], function(){
			var $ = layui.$,
			a = layui.admin,
			f = layui.form,
			b = $("body");
			f.render();
			
			b.on("click", "#LAY-user-get-vercode", function() {
				$(this);
				this.src = layui.setter.base + "/imageCodes?t=" + (new Date).getTime()
			}),
			//提交
			f.on("submit(LAY-user-login-submit)", function(t){
				//请求登入接口
				a.req({
					url: layui.setter.base + "/login",
					data: t.field,
					done: function(res){
						//登入成功的提示与跳转
						layer.msg(res.msg, {
							offset: "15px",
							icon: 1,
							time: 1500
						}, function(){
							location.href = layui.setter.base + "/home";
						});
					}
				});
			});
		});
	#end
</body>
</html>